<style>
    .ly-box-check-group{
        display: flex;
        flex-flow: row;
    }
</style>
<template>
    <div class="ly-box-check-group">
        <slot>
        </slot>
    </div>
</template>
<script>
    //这里定义组件
    Rap.define('', [], {
        name: 'ly-checkbox-group',
        props: {
            value: {
                'default': false
            }
        },
        watch: {
            'value': function (value) {
                if(!(value instanceof Array)){
                    value=[];
                }
                this.values=value;
                var children = this.$children;
                for(var i=0;i<children.length;i++){
                   var child=children[i];
                    child.computeCheck(value);
                }
            }
        },
        data: function () {
            return {
                values:[],
                check_group_id: 1
            }
        },
        init: function() {
            if (this.value && this.value.length > 0) {
                this.values = this.value;
            }
        },
        methods: {
            itemChange: function (value) {
                var index=this.values.indexOf(value);
                if(this.values.indexOf(value)>-1){
                    this.values.splice(index, 1);
                }else{
                    this.values.push(value);
                }
                this.$emit('input', this.values)

            }
        }
    })
</script>